Loading
Scriptbox
 VBScript Links 
 About VBscript 
 JavaScript Links 
 About JavaScript 
 Powershell Links 
 PSCRIPT the Script Launcher 
 PowerShell Shortcut Keys 
 About Powershell 
     VBScript
    JavaScript
    Powershell
Disclaimer
Contact
Latest 10 Scripts
Script search
  :: { Category } :: 0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ
         

Search Options:  Prevent  second  Instance  of  a  Script  

 Content of Prevent second Instance of a Script.vbs
MD5 Hash: 460F604F875DFFF8A6DCFE980ACCF7D4
Dim App : Set App = new cApp

If App.PrevInstance() = True then
msgbox "There is more then one Instance of this Script"
Else
msgbox "No other Instance running!"
End if


Class cApp

Private Sub Class_Initialize()

End Sub

Private Sub Class_Terminate()

End Sub

' ----------------------------
Public Function PrevInstance()

Dim strComputer : strComputer = "."
Dim oWMIService : Set oWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Dim colItems : Set colItems = oWMIService.ExecQuery("Select * From Win32_Process")
Dim sScriptCommandLine : sScriptCommandLine = wscript.ScriptFullName

Dim iCount : iCount = 0

For Each oItem in colItems
If InStr(oItem.CommandLine, sScriptCommandLine) > 0 and InStr(UCase(oItem.CommandLine), "CSCRIPT.EXE") > 0 or InStr(UCase(oItem.CommandLine), "WSCRIPT.EXE") > 0 Then
iCount = iCount +1
End If
Next

If iCount > 1 then
PrevInstance = True
Else
PrevInstance = False
End if

End Function

End Class

   © 2008 - 2013 Boris Toll      :: Scripts available: 6.481 ::      :: scriptbox.toll.at ::      :: powered by www.toll.at ::
  Google Entries:n/a
  Yahoo Backlinks:n/a
  Live Backlinks:n/a
  del.icio.us Bookmarks:n/a
  Technorati Links:n/a